package redstone;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
     
public class ExampleEntityListener implements Listener {

    public static Example plugin;

    public ExampleEntityListener(Example instance) {
        plugin = instance;
        Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
    }

    @EventHandler(priority = EventPriority.LOW)
    public void onEntityDamage(EntityDamageEvent event) {

        if(event.getEntity() instanceof Player){
        //If the entity being damaged is a player then...

                event.setCancelled(true);
        //Cancel the damage event, this will give the player unlimited health
        }
    }

}

